import java.io.Reader;
import java.util.List;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.destiny.account.dao.CustomerDao;
import org.destiny.account.entity.Customer;

public class UserDaoTest {
    public static void main(String[] args) throws Exception
    {
        String resource = "mybatis.cfg.xml";
        Reader reader = Resources.getResourceAsReader(resource);
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        SqlSessionFactory factory = builder.build(reader);
        
        SqlSession session = factory.openSession();
        CustomerDao dao = session.getMapper(CustomerDao.class);
        
        Customer cst = new Customer( "陈熄灯",1,"霞峰","大尖山","备注");
        dao.insert(cst);
        System.out.println("记录条数："+dao.countAll());
        
        List<Customer > users = dao.selectAll();
        for(Customer c : users){
        	c.printProps();
        }
        
//        dao.delete(1);
        
//        session.commit();
        session.close();
    }
}